"""
@description: Get "user_id", "username", and "user_type" from database, and generate a ".csv" file.
@author: Zzay
@create: 2022/07/11
"""
import pandas as pd
import numpy as np
import json
import requests


def get_people_info(people_info_path):
    """
    Get people information from the given file.
    :param people_info_path: Path of the file that records the information of people known to the system.
    """
    id_card_to_name = {}
    id_card_to_type = {}

    # read data from the csv file
    dataset = pd.read_csv(people_info_path)
    for i, row in dataset.iterrows():
        id_card_to_name[row[0]] = row[1]
        id_card_to_type[row[0]] = row[2]

    return id_card_to_name, id_card_to_type


def get_facial_expression_info(facial_expression_info_path):
    """
    Get facial expression information from the given file.
    :param facial_expression_info_path: Path of the file that records the information of built-in facial expression.
    """
    facial_expression_id_to_name = {}

    # read data from the csv file
    dataset = pd.read_csv(facial_expression_info_path)
    for i, row in dataset.iterrows():
        facial_expression_id_to_name[row[0]] = row[1]

    return facial_expression_id_to_name


'''
def generate_people_info(people_info_path):
    resources = requests.get('http://127.0.0.1:5000/oldpeoplemanagement/api/getinfolist')
    old_people_info_content = resources.content.decode('utf-8')
    
    resources = requests.get('http://127.0.0.1:5000/employeemanagement/api/getinfolist')
    employee_info_content = resources.content.decode('utf-8')
    
    #people_info.bak.csv
    
generate_people_info('')


a = '''
{
    "json_list": [
        {
            "id": 55,
            "name": "测试"
        },
        {
            "id": 57,
            "name": "工作人员"
        },
        {
            "id": 58,
            "name": "工作人员2"
        },
        {
            "id": 59,
            "name": "工作人员3"
        }
    ]
}
'''
b = json.loads(a)
c = b['json_list']
for i in c:
    print(i['id'], i['name'])
'''
